{% extends 'BudgetBudgetBundle::layout.html.twig' %}

{% block javascripts %}
    {% javascripts '@BudgetBudgetBundle/Resources/public/js/*' %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}
    
    <script type="text/javascript">
      $( document ).ready(function() {
         $('.showConfirmMsg').click(function(){
            return expense.showConfirmMsg();
         });
      });
    </script>
{% endblock %}
        
{% block home_content %}
 <div class="container">
    <table class="table">
        
        {% for category in expenses %}        
            <thead>
                <tr>
                    <th>{{ category.name }} ({{ category.expenses|length}})</th> 
                    <th></th>
                    <th></th>
                    <th></th>
                </tr>
                {% if category.expenses|length %}
                    <tr>
                        <th>Price:</th> 
                        <th>Comment</th>
                        <th>Date:</th>
                        <th>Action:</th>
                    </tr>
                {% endif %}
            </thead>

            {% if category.expenses|length %}
            <tbody>
                {% for expense in category.expenses %}
                <tr>
                    <td>{{ expense.price }} €</td>
                    <td>{{ expense.comment }}</td>
                    <td>{{ expense.dateCreated|date('d.m.Y') }}</td>
                    <td>
                        <a href="{{ path('BudgetBudgetBundle_expenses_del', {id: expense.id}) }}" title="Delete Expense" class="showConfirmMsg"><span class="glyphicon glyphicon-remove-circle"></span></a>
                        <a href="{{ path('BudgetBudgetBundle_expenses_edit', {id: expense.id}) }}" title="Edit Expense"><span class="glyphicon glyphicon-edit"></span></a>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
            {% endif %}

        {% endfor %}
    </table>
 </div>        
{% endblock %}
